//
//  ZQPendingOrderPage.m
//  jianzhik
//
//  Created by huami on 2018/8/30.
//  Copyright © 2018年 WKWebView. All rights reserved.
//
#import "BRPickerView.h"
#import "ZQPendingOrderPage.h"
#import "ZQPendingOrderTableViewCell.h"
#import "ZQPendingModel.h"
#import <MJExtension/MJExtension.h>
#import "UIBarButtonItem+item.h"
@interface ZQPendingOrderPage ()
/** listMuArr */
@property (nonatomic, strong) NSMutableArray *listMuArr;
/** status */
@property (nonatomic, strong) NSNumber *status;
@end

@implementation ZQPendingOrderPage
- (NSMutableArray *)listMuArr
{
    if (!_listMuArr) {
        _listMuArr = [[NSMutableArray alloc] init];
    }
    return _listMuArr;
}

- (NSNumber *)status
{
    if (!_status) {
        _status = [[NSNumber alloc] init];
    }
    return _status;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    parameters[@"Status"] = self.status;
    [ZQAFHelper afnetworkRequestWithPostURL:@"/v1/work/listwork" parameters:parameters view:self.view finishedBlcok:^(NSDictionary *dict) {
            //        dict[Data]
        NSArray *arr = dict[@"Data"];
        if (arr.count == 0) {
            [UIHelper showTipsWithText:@"查无数据" inView:self.view];
            [self.listMuArr removeAllObjects];
            [self.tableView reloadData];
            return ;
        }
        self.listMuArr = [ZQPendingModel mj_objectArrayWithKeyValuesArray:dict[@"Data"]];
            [UIHelper dismissLoadingInView:self.view];
            [self.tableView reloadData];
    }];
    
    UINavigationBar *navBar = self.navigationController.navigationBar;
    //    // 设置导航栏标题字体大小
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:18];
    attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
    [navBar setTitleTextAttributes:attrs];
    [navBar setBarTintColor:kTinColor];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self registerCell:[ZQPendingOrderTableViewCell class]];
    self.tableView.backgroundColor = [UIColor stringToColor:@"#d7d7d7"];
    self.tableView.contentInset = UIEdgeInsetsMake(10, 0, 0, 0);
    self.status = @10;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.listMuArr.count > 20 ? 20 : self.listMuArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 139;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ZQPendingModel *model = self.listMuArr[indexPath.row];
    ZQPendingOrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID  forIndexPath:indexPath];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    cell.penModel = model;
    return cell;
}
@end
